/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hu.elte.progelm2.ejb.simulator;

/**
 *
 * @author ntb
 */
public class Pair {

    public Object o1;
    public Object o2;

    public Pair(){
    }

    public Pair(Object o1, Object o2) {
        this.o1 = o1;
        this.o2 = o2;
    }

    public static boolean same(Object o1, Object o2) {
        return o1 == null ? o2 == null : o1.equals(o2);
    }

    public Object getFirst() {
        return o1;
    }

    public Object getSecond() {
        return o2;
    }

    public void setFirst(Object o) {
        o1 = o;
    }

    public void setSecond(Object o) {
        o2 = o;
    }

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof Pair)) {
            return false;
        }
        Pair p = (Pair) obj;
        return same(p.o1, this.o1) && same(p.o2, this.o2);
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 59 * hash + (this.o1 != null ? this.o1.hashCode() : 0);
        hash = 59 * hash + (this.o2 != null ? this.o2.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return "Pair{" + o1 + ", " + o2 + "}";
    }
}
